import { ElMessage } from 'element-plus'
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useCareerStore = defineStore('main', () => {
    //保存增加的数据
    const carerrPost = ref([])

    //添加或修改数据
    const addmesaage = (obj) => {
        const data = carerrPost.value.find(item => item.id == obj.id)
        if (data) {
            data.id = obj.id,
                data.name = obj.name,
                data.job = obj.job,
                data.valueHtml = obj.valueHtml,
                data.valueHtml1 = obj.valueHtml1,
                data.zip = obj.zip
            ElMessage('修改成功')
        } else {
            carerrPost.value.push(obj)
            ElMessage('添加成功')
        }
    }

    //回显数据
    const echo = (id) => {
        return carerrPost.value.find(item => item.id == id)
    }
    return {
        carerrPost,
        addmesaage,
        echo
    }
},
    {
        persist: true
    })